/******************************************************************************************
 
Made by www.Flashphoner.com, all rights reserved.
These sources can only be used for working with Flashphoner server.
If you want use this to create your own application (separate from Flashphoner server) � 
please contact support@flashphoner.com 

******************************************************************************************/

package com.flashphoner.phone
{
	import com.flashphoner.api.Flash_API;
	import com.flashphoner.phone.views.CallView;
	import com.flashphoner.phone.views.IncomingView;
	import com.flashphoner.phone.views.MicrophoneSettingsView;
	import com.flashphoner.phone.views.PhoneButton;
	import com.flashphoner.phone.views.SipAccountView;
	import com.flashphoner.phone.views.TransferView;
	import com.flashphoner.phone.views.VersionView;
	
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	
	import mx.collections.ArrayCollection;
	import mx.controls.List;
	
	/**
	 * Data of phone widget
	 **/
	public class DataPhone
	{
		private static var data:DataPhone;
		/** 
		 * Get instance of a singelton
		 **/		
		public static function getInstance():DataPhone{
			if (data == null){
				data = new DataPhone();
				data.flash_API = new Flash_API();
			}
			return data;
		}
		
		/** 
		 * Flash_API used for phone widget
		 **/		
		public var flash_API:Flash_API;
		
		/**
		 * Controller of events
		 **/
		public var viewController:ViewControllerPhone = new ViewControllerPhone();
		
		/**
		 * list of calls in phone
		 **/
		public var listCalls:List;
		
		/**
		 * Instance of incomming view
		 **/
		public var incommingView:IncomingView = new IncomingView();
		
		/**
		 * Instance of transfer view
		 **/
		public var transferView:TransferView = new TransferView();		

		/**
		 * Instance of sip account view
		 **/
		public var sipAccountView:SipAccountView = new SipAccountView();

		/**
		 * Instance of microphone settings view
		 **/
		public var microphoneSettingsView:MicrophoneSettingsView = new MicrophoneSettingsView();

		/**
		 * Instance of version view
		 **/
		public var versionView:VersionView;		
		
		/**
		 * Get object of CallView which corresponds call
		 * @param callId identifier of call
		 **/
		public function getCallView(callId:String):CallView{
			var index:Number = flash_API.getIndexByCallId(callId);
			var obj:* = listCalls.indexToItemRenderer(index);
			return obj as CallView;
			
		}
	}
}